package com.tarena.charging.device.repository;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tarena.charging.device.mapper.StationMapper;
import com.tarena.charging.device.po.StationPO;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class StationRepository {
    @Autowired
    private StationMapper stationMapper;

    public List<StationPO> getAll() {
        //select * from charging_station
        return stationMapper.selectList(null);
    }

    public Integer getIdByName(String name) {
        //select * from charging_station where station_name=#{}
        //准备持久层mybatis-plus的where条件
        QueryWrapper<StationPO> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("station_name",name);
        return stationMapper.selectOne(queryWrapper).getId();
    }

    public StationPO getById(Integer id) {
        return stationMapper.selectById(id);
    }
}
